// 判断用户是否登陆
(async function () {

    let Business = cookie.get('Business') ? cookie.get('Business') : "{}";


    //try catch 捕捉异常
    try {
        if (Business == 'undefined') {
            Business = null
        } else {
            Business = JSON.parse(Business)
        }
    } catch {
        Business = null
    }

    if (!Business || JSON.stringify(Business) == "{}") {
        mui.toast('未登陆，请先去登陆');
        setTimeout(() => {
            location.href = 'login.html'
        }, 1000)
    }

    let result = await POST({
        url: 'business/check', params: {
            id	: Business.id  ?? 0,
            mobile: Business.mobile ?? '',
        }
    })

    if (result.code == 0) {
        cookie.clear();
        mui.toast('非法登陆');
        setTimeout(() => {
            location.href = 'login.html'
        }, 1000)
    } else {
        cookie.set('Business', JSON.stringify(result.data))
    }
})();